package g

import (
	"reflect"
	"testing"
)

func Test_postorderTraversal(t *testing.T) {
	type args struct {
		root *TreeNode
	}
	tests := []struct {
		name string
		args args
		want []int
	}{
		{"1", args{GetTreeNode([]int{1, null, 2, 3})}, []int{3, 2, 1}},
		{"2", args{GetTreeNode([]int{})}, nil},
		{"3", args{GetTreeNode([]int{1, 2, 3, 4, 5, null, null, 6, null, null, 8, null, 7, null, 9})},
			[]int{7, 6, 4, 9, 8, 5, 2, 3, 1}},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := postorderTraversal(tt.args.root); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("inorderTraversal() = %v, want %v", got, tt.want)
			}
		})
	}
}
